package com.learn.life;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
 * @description: 如果加了@Configuration注解，就是代理对象，会从Spring容器获取对象，同时里面的对象是单例；反之则
 * @author: cong zhi
 * @createDate: 2022/5/26 16:47
 * @updateUser: cong zhi
 * @updateDate: 2022/5/26 16:47
 * @updateRemark: 修改内容
 * @version: v1.0
 */
@Configuration
@Import(MyBeanDefinitionRegistryPostProcessor.class)
@ComponentScan("com.learn.life")
public class MyConfig {


    @Bean(initMethod = "myInit", destroyMethod = "myDestory")
    public Person person() {
        return new Person();
    }


    @Bean
    public Person person1() {
        return person();
    }


    @Bean
    public User factoryBean() throws Exception {
        return new MyFactoryBean().getObject();
    }

}
